package com.coder.rental.config;

import com.coder.rental.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalException {
    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e) {
        /*Result result=new Result();
        result.setCode(ResultCode.ERROR);
        result.setMessage(e.getMessage());*/
        log.error("异常信息: {}", e.getMessage());
        log.error("异常堆栈:{}",e.toString());
        return Result.fail().setMessage(e.getMessage());
    }
}
